Skip to content

feat(routing): add opt-in bandit route-order recommendations - #49

Merged
ALikesToCode merged 1 commit into
integrate/gateway-waves-1-4from
feat/bandit-recommendations
Oct 9, 2026
Merged

ALikesToCode merged 1 commit into
integrate/gateway-waves-1-4from
feat/bandit-recommendations

Conversation

@ALikesToCode

Copy link
Copy Markdown
Owner

Summary

Adds opt-in route-order recommendations behind BANDIT_MODE: off (the default), shadow or recommendation. With it off, existing evaluation proposals, the shadow apply route and request dispatch are unchanged, and the two new admin routes return 404.

  • Inputs:
    • Cells are built per task type and model, from stored evaluation results plus administrator feedback.
    • Feedback needs a single-use nonce tied to a stored sample.
    • Each cell needs at least 50 samples, observations decay with a 7-day half-life, and the existing evaluation noise floor gates any difference.
    • Unknown cost or quality is never treated as cheap or good.
  • Output: POST /admin/workbench/shadow/propose returns base_revision, eligible_order_before, eligible_order_after, the evidence (sample counts, coverage, quality, measured cost, 95% intervals) and the uncertainty. A proposal moves at most one position, and a fixed seed gives the same result.
  • Applying a proposal: only through the existing reviewed configuration snapshot apply, with its compare-and-swap revision check; a stale revision gets 409. While the mode is on, the old shadow apply route refuses (400) so there is only one way to change route order.
  • Safety: neither mode calls a provider, duplicates a request, explores paid candidates or writes route policy. No remote classifier is used.
  • Limits:
    • Bounded to 1,000 cells and 10,000 observations.
    • Feedback and nonces live in the process and are lost on restart; this is documented.

Details are in docs/bandit-recommendations.md.

Shared registrations

  • Added BANDIT_MODE to the Container env keys.
  • Added app.post('/admin/workbench/shadow/bandit/nonce') and app.post('/admin/workbench/shadow/bandit/feedback') to the Flask route inventory. Both are administrator-only dashboard routes, protected by CSRF, and dispatch to no provider.

Tests

  • tests/test_bandit_recommendations.py covers:
    • sparse cells;
    • unknown costs;
    • the noise gate;
    • nonce replay;
    • determinism;
    • the one-position limit;
    • stale revisions;
    • no route write and no extra calls in either mode.
  • Full Python suite: 3,920 passed, 2 skipped. ruff, mypy and bandit are clean.
  • npm run test:worker: 1,460 passed. npm run test:integration: 7 passed.
  • test:deploy, free routes, client headers and the wrangler deploy --dry-run bundle all pass.

CI notes

  • GitHub python/node jobs: the dependency-audit steps fail on every branch, including main. fix(deps): clear the CI dependency audit advisories #42 fixes that.
  • Workers Builds: fails on this stack because the Wave 3 base adds the AdmissionCoordinator Durable Object migration, which wrangler versions upload cannot apply. This is expected until wrangler deploy runs on main.

This is part of Wave 5. It is based on integrate/gateway-waves-1-4, the Wave 4 integration branch. The README line comes with the Wave 5 integration PR.

Behind BANDIT_MODE (off, shadow or recommendation; default off), build task/model cells from stored evaluation results and nonce-protected administrator feedback, gate them on sample count, decay and the evaluation noise floor, and propose at most a one-position move in an automatic route's eligible order. Neither mode calls a provider or writes route policy; a proposal is applied only through the reviewed configuration snapshot apply with its revision check. Unknown cost or quality never ranks as favourable.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e50e1607-7ff8-4998-95c3-4fce02eb1f99

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
multillm-proxy 64037f4 Oct 09 2026, 01:27 AM

@ALikesToCode
ALikesToCode merged commit 2037c03 into integrate/gateway-waves-1-4 Oct 9, 2026
4 of 7 checks passed
@ALikesToCode
ALikesToCode deleted the feat/bandit-recommendations branch October 26, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant